﻿using Microsoft.Xna.Framework;

namespace ThinkDotNetBotApiCommon.Helpers
{
    public static class MathHelperEx
    {      
        public static double GetSignedAngleBetweenVectors(Vector2 vec1, Vector2 vec2)
        {
            if (vec1 == vec2) return 0;
            vec1.Normalize();
            vec2.Normalize();
            float cosAngle = Vector2.Dot(vec1, vec2);
            double angle = System.Math.Acos(cosAngle);

            if (vec2.X < vec1.X)
                return -angle;

            return angle;
        }
        public static double GetAngleBetweenVectors(Vector2 vec1, Vector2 vec2)
        {
            if (vec1 == vec2) return 0;
            vec1.Normalize();
            vec2.Normalize();
            float cosAngle = Vector2.Dot(vec1, vec2);
            double angle = System.Math.Acos(cosAngle);

            if (vec2.X < vec1.X)
                return 2 * System.Math.PI - angle;

            return angle;
        }      
    }
}
